Overview
TheProductoModel class provides simple read-only access to the product catalog stored in the producto database table. It supports listing all available products and retrieving individual product details by item code.
Database Table: producto
Key Responsibilities:
- List all products for selection interfaces
- Retrieve product details by item code
- Provide product information for return registration
This model only implements read operations. Product catalog management (create, update, delete) is handled through separate administrative interfaces not included in the DevolutionSync core.
Constructor
Conexion::Conectar().
Methods
listarTodos()
array - Array of associative arrays with the following structure:
Product item code (unique identifier)
Product description or name
obtenerPorItem()
The product item code to search for (e.g., “PROD001”)
array|false - Associative array with product data, or false if not found
Product item code (matches the search parameter)
Product description or name
Database Schema
Table:producto
The producto table contains the complete product catalog with inventory control fields:
| Column | Type | Description | Used by Model |
|---|---|---|---|
id | INT (PK, AUTO_INCREMENT) | Primary key | No |
item | VARCHAR (UNIQUE) | Product item code | Yes |
descripcion | VARCHAR | Product name/description | Yes |
minimo | DECIMAL | Minimum inventory level | No |
maximo | DECIMAL | Maximum inventory level | No |
pesoProm | DECIMAL | Average weight per unit | No |
Why are inventory fields not exposed?
Why are inventory fields not exposed?
The
ProductoModel class intentionally excludes minimo, maximo, and pesoProm fields because:- Return registration doesn’t require inventory data - Auxiliary users only need to identify the product (item + descripcion)
- Separation of concerns - Inventory management is handled by separate warehouse systems
- Simplified API - Reduces payload size and complexity for frontend interfaces
- Data privacy - Internal inventory targets are not exposed to all auxiliary users
cantidad_kg from pesoProm × cantidad_und), you can extend the model:Integration with DevolucionModel
TheProductoModel is typically used in conjunction with DevolucionModel during the return registration workflow:
Frontend Integration Examples
Select Dropdown with All Products
AJAX Autocomplete
Performance Considerations
Caching Recommendation: Since product catalogs are relatively static, consider implementing caching for This reduces database load when multiple users register returns simultaneously.
listarTodos() results:Related Models
- DevolucionModel - Uses product data for return registration
- UsuarioModel - User management for product catalog access